package com.ct.gd.passport.view.policy;

import android.content.Intent;
import android.view.View;
import android.widget.ListView;

import com.ct.gd.passport.common.constants.UmengVar;
import com.ct.gd.passport.domain.PolicyCatalog;
import com.ct.gd.passport.view.BundleKeys;
import com.ct.gd.passport.view.RootCatalogFragment.OnRootChangedListener;
import com.umeng.analytics.MobclickAgent;
import com.up91.common.android.view.adapter.SimpleListAdapter;

public class PolicyCatalogFragment extends AbsPolicyCatalogFragment implements OnRootChangedListener<PolicyCatalog>{

	@Override
	protected SimpleListAdapter<PolicyCatalog> onInitListAdapter() {
		return new PolicyCatalogListAdapter(getActivity(), null);
	}

	@Override
	public void onListItemClick(ListView l, View v, int position, long id) {
		MobclickAgent.onEvent(getActivity(), UmengVar.POLICY_DETAIL);
		PolicyCatalog info = (PolicyCatalog)l.getItemAtPosition(position);
		
		// enter detail
		Intent intent = new Intent(this.getActivity(), PolicyDetailActivity.class);
		intent.putExtra(BundleKeys.CATALOG_ID, info.getCatalogId());
		startActivity(intent);
	}
	
	@Override
	public void onRootChanged(PolicyCatalog catalog) {
		setCatalog(catalog);
		loadCatalog();
	}
}
